<template>
  <view class="waterfall-box">
    <view class="comp-it" :style="{width: props.width}" v-for="(n, m) in 2" :key="n">
      <template v-for="(item,index) in props.list" :key="item.id">
        <template v-if="props.showBannerBox && m === 0 && index === 0">
          <BannerBox type="discover_index" banner-style="width: 332rpx;height: 460rpx; margin-bottom: 24rpx;"></BannerBox>
        </template>
        <itemCompos v-if="index % 2 === m" :customerId="props.customerId" :item="item" @onFollow="onFollow" :origin="props.origin" :relatedTopic="props.relatedTopic" :marginBottom="props.marginBottom" />
      </template>
    </view>
  </view>
</template>

<script setup>
import itemCompos from './itemCompos'
import BannerBox from '@/components/banner/panel'
const props = defineProps({
  list: {
    type: Array,
    required: true
  },
  origin: {
    type: String,
    default: 'list'
  },
  relatedTopic: {
    type: String,
    default: ''
  },
  customerId: {
    type: String,
    default: ''
  },
  showBannerBox: {
    type: Boolean,
    default: false
  },
  width: {
    type: String,
    default: '330rpx'
  },
  marginBottom: {
    type: String,
    default: '30rpx'
  }
})
const emit = defineEmits(['onFollow'])
const onFollow = (item) => {
  emit('onFollow', item)
}
</script>

<style scoped lang="scss">
.waterfall-box{
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
</style>
